package cn.edu.fzu.homemaking.company.session;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpSession;

public class UserSessionRequest extends HttpServletRequestWrapper {

    private final UserSession session;

    public UserSessionRequest(HttpServletRequest request, UserSession session) {
        super(request);
        ServletRequestAttributes attributes = new ServletRequestAttributes(this);
        RequestContextHolder.setRequestAttributes(attributes);
        this.session = session;
    }


    @Override
    public HttpSession getSession() {
        return session;
    }


    @Override
    public HttpSession getSession(boolean create) {
        return session;
    }

}
